#!/usr/bin/python3
# -*- coding: utf-8 -*-
import time

import mistune

from custom_renderer import CustomRenderer

def get_current_time():
    return time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(time.time()))

def read_markdown(filename):
    with open(filename) as fd:
        text = fd.read()
    return text

def parse_markdown(md):
    outputMarkdownContent  = read_markdown(md)

    myRenderer = CustomRenderer()
    markdown = mistune.Markdown(render=myRenderer)
    outputHtml = markdown(outputMarkdownContent)
    
    with open("{}-index.html".format(get_current_time()), 'w') as fd:
        fd.write(outputHtml)

def unittest():
    parse_markdown("README.md")

if __name__ == '__main__':
    unittest()
